import Vue from 'vue'

import message from './message'

const messages = Vue.extend(message)

const instance = new messages({
    el: document.createElement('div')
})

instance.show = false

const $message = {
    show(msg) {
        instance.show = true
        instance.msg = msg
        document.body.appendChild(instance.$el)
    },
    hide() {
        instance.show = false
    }
}

export default{
    install(){
        if(!Vue.$message){
            Vue.$message=$message
        }
        Vue.mixin({
            created(){
                this.$message=Vue.$message
            }
        })
    }
}